/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package petstore.view.action.atendimento;

import petstore.view.action.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import petstore.business.IAtendimentoFacade;
import petstore.business.IComumFacade;
import petstore.model.Animal;
import petstore.model.enumeration.Sexo;

/**
 *
 * @author Tom Hayden
 */
public class ProntuarioAction extends CustomDispatchAction {

    private IAtendimentoFacade atendimentoFacade;
    private IComumFacade comumFacade;
    
    public void setAtendimentoFacade(IAtendimentoFacade atendimentoFacade) {
        this.atendimentoFacade = atendimentoFacade;
    }

    public void setComumFacade(IComumFacade comumFacade) {
        this.comumFacade = comumFacade;
    }

    public ActionForward preparar(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        Animal animal = (Animal) request.getSession().getAttribute("animal");
        request.getSession().setAttribute("cliente", animal.getCliente());
        request.getSession().setAttribute("especies", this.comumFacade.listarEspecie());
        request.getSession().setAttribute("racas", this.comumFacade.listarRaca());
        request.getSession().setAttribute("portes", this.comumFacade.listarPorte());
        request.getSession().setAttribute("pelagens", this.comumFacade.listarPelagem());
        request.getSession().setAttribute("vacinas", this.comumFacade.listarVacina());
        request.getSession().setAttribute("vermifugos", this.comumFacade.listarVermifugo());
        request.getSession().setAttribute("exames", this.comumFacade.listarExame());
        request.getSession().setAttribute("sexoMasculino", Sexo.M);
        request.getSession().setAttribute("sexoFeminino", Sexo.F);
        
        request.getSession().setAttribute("anamneses", this.atendimentoFacade.listarAnamnesePorAnimal(animal));
        request.getSession().setAttribute("examesSolicitados", this.atendimentoFacade.listarExameSolicitadoPorAnimal(animal));
        request.getSession().setAttribute("pesagens", this.atendimentoFacade.listarPesagemPorAnimal(animal));
        request.getSession().setAttribute("receitas", this.atendimentoFacade.listarReceitaPorAnimal(animal));
        request.getSession().setAttribute("pendencias", this.atendimentoFacade.listarPendenciaPorAnimal(animal));

        return mapping.findForward("dadosAnimal");

    }

}
